package joinDemo;

public class Demo {
    public static void main(String[] args) throws InterruptedException {
        Thread p = new Thread(() ->{
            for (int i = 1; i <= 5; i++) {
                System.out.println("我在生产" );
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("我生产完了");
        });
        Thread c = new Thread(() ->{
            for (int i = 1; i <= 5; i++) {
                System.out.println("我在消费");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        p.start();
        p.join();
        c.start();
    }
}
